﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace QuestPrototype
{
    public class Input
    {
        public static KeyboardState CurrentKeyState;
        public static KeyboardState LastKeyState;
        public static MouseState CurrentMouseState;
        public static MouseState LastMouseState;

        public static void Update()
        {
        LastKeyState = CurrentKeyState;
        CurrentKeyState = Keyboard.GetState();
        LastMouseState = CurrentMouseState;
        CurrentMouseState = Mouse.GetState();
        }

        public static bool KeyDown(Keys key)
        {
            return CurrentKeyState.IsKeyDown(key);
        }

        public static bool KeyPressed(Keys key)
        {
            if (CurrentKeyState.IsKeyUp(key) && LastKeyState.IsKeyDown(key))
            {
                return true;
            }
            return false;
        }

        public static bool MouseDown(string key)
        {
            if (key == "Left")
            {
                return CurrentMouseState.LeftButton == ButtonState.Pressed;
            }

            if (key == "Right")
            {
                return CurrentMouseState.RightButton == ButtonState.Pressed;
            }
            return false;

        }

        public static bool MouseClicked(string key)
        {
            if (key == "Left")
            {
                return CurrentMouseState.LeftButton == ButtonState.Released && LastMouseState.LeftButton == ButtonState.Pressed;
            }

            if (key == "Right")
            {
                return CurrentMouseState.RightButton == ButtonState.Released && LastMouseState.RightButton == ButtonState.Pressed;
            }
            return false;

        }

    }
}
